//package com.rc.saas.mini.controller.elec;
//
//import com.github.pagehelper.PageInfo;
//import com.rc.saas.base.MinipBaseController;
//import com.rc.saas.mini.common.base.TResponse;
//import com.rc.saas.mini.common.constant.SessionConstants;
//import com.rc.saas.mini.facede.ElecStationAssemble;
//import com.rc.saas.mini.minip.vo.LoginInfoVo;
//import com.rc.saas.mini.model.elec.ElecStation;
//import com.rc.saas.mini.model.member.MemberInfo;
//import com.rc.saas.mini.search.ElecStationSearch;
//import com.rc.saas.mini.service.elec.ElecStationCollectService;
//import com.rc.saas.mini.service.elec.ElecStationService;
//import com.rc.saas.mini.service.member.MemberInfoService;
//import com.rc.saas.mini.vo.elec.CountPileVo;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.apache.commons.lang3.StringUtils;
//import org.apache.logging.log4j.LogManager;
//import org.apache.logging.log4j.Logger;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.MediaType;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import springfox.documentation.annotations.ApiIgnore;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpSession;
//
///**
// * @author wangzhengwei
// * @create 2021/4/27
// */
//@Controller
//@RequestMapping("/elecStation/collect")
//@Api(tags = "收藏信息")
//public class ElecStationCollectController extends MinipBaseController {
//    private static Logger logger = LogManager.getLogger(ElecStationCollectController.class);
//
//    @Autowired
//    private MemberInfoService memberInfoService;
//
//    @Autowired
//    private ElecStationService elecStationService;
//
//    @Autowired
//    private ElecStationAssemble elecStationAssemble;
//
//    @Autowired
//    private ElecStationCollectService elecStationCollectService;
//
//    /** 获取收藏桩群列表 */
//    @ResponseBody
//    @RequestMapping("/listPageCollectStation")
//    @ApiOperation(value = "获取收藏桩群列表(需要登录)", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "longitude", paramType = "query", value = "手机经度", required = false),
//            @ApiImplicitParam(name = "latitude", paramType = "query", value = "手机纬度", required = false),
//            @ApiImplicitParam(name = "pageNo", paramType = "query", value = "页码（默认1）", required = false),
//            @ApiImplicitParam(name = "pageSize", paramType = "query", value = "页大小（默认10）", required = false)})
//    public TResponse listPageCollectStation(@ApiIgnore HttpSession session, ElecStationSearch search,
//                                        @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
//                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
//        String tenantCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_TENANT);
//        if (tenantCode == null || StringUtils.isBlank(tenantCode)) {
//            logger.error("找不到对应运营商信息:{}", tenantCode);
//            return TResponse.FAIL("找不到对应运营商信息");
//        }
//        LoginInfoVo loginInfo = readLoginInfo(request);
//        if (loginInfo == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//
//        MemberInfo member = memberInfoService.selectByPrimaryKey(loginInfo.getMemberId());
//        if (member == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//        logger.info("ElecStationCollectController.listPageCollectStation.tenantCode:{},mobile:{}", tenantCode, member.getMobile());
//        search.setMemberId(member.getMemberId());
//
//        PageInfo<ElecStation> page = elecStationService.listPageCollectByMember(search, pageNo, pageSize);
//        //获取价格
//        CountPileVo countPileVo = new CountPileVo();
//        countPileVo.setElecStationFindVos(elecStationAssemble.assembleStationExtInfo(tenantCode, member, page.getList()));
//        countPileVo.setPages(page.getPages());
//        return TResponse.SUCCESS_DATA(countPileVo);
//    }
//
//    /**
//     * 桩群收藏状态判断
//     */
//    @ResponseBody
//    @RequestMapping("/isCollected")
//    @ApiOperation(value = "是否收藏(需要登录)", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiImplicitParams({@ApiImplicitParam(name = "elecStationId", paramType = "query", value = "桩群ID", required = false)})
//    public TResponse isCollected(@ApiIgnore HttpSession session, Long elecStationId) {
//        String tenantCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_TENANT);
//        if (tenantCode == null || StringUtils.isBlank(tenantCode)) {
//            logger.error("找不到对应运营商信息:{}", tenantCode);
//            return TResponse.FAIL("找不到对应运营商信息");
//        }
//        LoginInfoVo loginInfo = readLoginInfo(request);
//        if (loginInfo == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//
//        MemberInfo member = memberInfoService.selectByPrimaryKey(loginInfo.getMemberId());
//        if (member == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//        logger.info("ElecStationCollectController.isCollected.tenantCode:{}:mobile:{},stationId:{}", tenantCode, member.getMobile(), elecStationId);
//
//
//        String collect = elecStationCollectService.selectCollectStatus(member.getMemberId(), elecStationId) ? "1" : "0";
//        return TResponse.SUCCESS_DATA(collect);
//    }
//
//    /**
//     * 修改桩群收藏状态
//
//     */
//    @ResponseBody
//    @RequestMapping("/updateCollectStation")
//    @ApiOperation(value = "收藏/取消收藏桩群(需要登录)", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "elecStationId", paramType = "query", value = "桩群ID", required = false),
//            @ApiImplicitParam(name = "opType", paramType = "query", value = "操作类型(0做取消收藏 1 做收藏)", required = false)})
//    public TResponse updateCollectStation(@ApiIgnore HttpSession session, Long elecStationId, String opType) {
//        String tenantCode = (String) request.getSession().getAttribute(SessionConstants.SESSION_TENANT);
//        if (tenantCode == null || StringUtils.isBlank(tenantCode)) {
//            logger.error("找不到对应运营商信息:{}", tenantCode);
//            return TResponse.FAIL("找不到对应运营商信息");
//        }
//        LoginInfoVo loginInfo = readLoginInfo(request);
//        if (loginInfo == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//
//        MemberInfo member = memberInfoService.selectByPrimaryKey(loginInfo.getMemberId());
//        if (member == null) {
//            return TResponse.FAIL_LOGIN();
//        }
//        logger.info("ElecStationCollectController.updateCollectStation.tenantCode:{}:mobile:{},stationId:{},opType:{}", tenantCode, member.getMobile(), elecStationId, opType);
//
//        try {
//            elecStationCollectService.saveCollectStatus(tenantCode,member.getMemberId(), elecStationId, opType);
//            return TResponse.SUCCESS("操作成功");
//        } catch (Exception e) {
//            return TResponse.FAIL("操作失败");
//        }
//    }
//
//}
